package com.sky.mapper;

import com.github.pagehelper.Page;
import com.sky.annotation.AutoFill;
import com.sky.dto.DishPageQueryDTO;
import com.sky.entity.Dish;
import com.sky.enumeration.OperationType;
import com.sky.vo.DishVO;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;
import java.util.Map;

@Mapper
public interface DishMapper {
//    @Select("select count(id) from dish where category_id = #{categoryId}")
//    int countByCategoryId(Long categoryId);

    @AutoFill(OperationType.INSERT)
    void insert(Dish dish);

    Page<DishVO> pageQuery(DishPageQueryDTO dish);

    @Select("select * from dish where category_id=#{id}")
    List<Dish>selectById(Long id);

    @Delete("delete from dish where id=#{id}")
    void deleteById(Long id);

    @AutoFill(OperationType.UPDATE)
    @Update("update dish set name=#{name},price=#{price},image=#{image},category_id=#{categoryId},update_time=#{updateTime},update_user=#{updateUser},status=#{status},description=#{description} where id=#{id}")
    void update(Dish dish);

    @Select("select * from dish where  id=#{id}")
    Dish getById(Long id);
    Integer countByMap(Map map);
}
